<?php
	require_once("functions.php");
	require_once("mdetect.php");
	
	header("X-UA-Compatible:IE=EmulateIE7");
	
	$uaInfo = new uagent_info;
	$uaInfo->InitDeviceScan();			//determine if the client is a mobile device
	if(!isLoggedIn()){					//check if logged in
		header("location:index.php?message=".urlencode("Please login first."));
		die();
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta name="keywords" content="Web, Dojo, Special Problem" />
        <meta name="description" content="A web-based UML diagramming tool" />
		<meta name="author" content="Robenie D. Fernandez; Rodolfo N. Duldulao, Jr." />
        <title>Home - <?php echo $_SESSION["username"] ?> - UML WebStudio</title>
        <link rel="stylesheet" type="text/css" href="lib/dojo/resources/dojo.css" />
        <link rel="stylesheet" type="text/css" href="lib/dijit/themes/soria/soria.css" />
        <link rel="stylesheet" type="text/css" href="lib/dijit/themes/nihilo/nihilo.css" />
		<link rel="stylesheet" type="text/css" href="lib/dojox/form/resources/FileInput.css" />
		
		<link rel="stylesheet" type="text/css" href="lib/toolbarIcons.css" />
		<link rel="stylesheet" type="text/css" href="lib/workspace.css"/>
		<link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
    </head>
    <body class="soria">
		<?php
			//if wap device, send error
			if($uaInfo->DetectWapWml()){
				echo "Sorry. This site can only be viewed on a more capable browser.<br />";
				echo '<img src="images/logo3.png" alt="logo" title="UML WebStudio" />';
				echo '</body></html>';
				die();
			}
		?>
        <div id="loader">
			<!--Block the screen until ready-->
            <div id="loaderInner">Loading...</div>
        </div>
		<?php 
			//flush the buffer and send to client to start processing 
			flush(); 
		?>
        <div dojoType="dijit.layout.BorderContainer" style="width:100%;height:100%">
			
			<div dojoType="dijit.MenuBar" region="top" class="nihilo">
				<?php include_once("page_components/menubar.html"); ?>
			</div>
			
			<!--Navigation pane-->
			<div dojoType="dijit.layout.ContentPane" style="width:12%" region="leading" splitter="true" minSize="100" class="nihilo">
				<div class="center">
					<img src="images/logo3.png" alt="logo" title="UML WebStudio" style="width:100%;" />
				</div>
				<br />
				<div id="navigation">
					<p class="center">
						<a href="javascript:viewProjects();"><span style="font-style:italic">Open a Project</span></a><br />
						<a href="javascript:newProject();"><span style="font-style:italic">Create a Project</span></a>
					</p>
				</div>
				<br />
            </div>
			
			<!--Main area-->
			<div id="tabContainer" dojoType="dijit.layout.TabContainer" region="center" tabStrip="true">
                <div id="homeTab" dojoType="dojox.layout.ContentPane" title="Home" selected="true" href="ajax/home.html" executeScripts="true" extractContent="true" ></div>
            </div>
			
			<!--Properties pane-->
			<div dojoType="dijit.layout.ContentPane" style="width:12%" region="trailing" splitter="true" minSize="100" id="propertiesPane">
				<h4 class="center">
					<span id="propertiesName"></span> Properties
				</h4>
				<div dojoType="dijit.form.Form" id="propertiesForm" jsId="propertiesForm" action="" onSubmit="return false">
					<div id="propertiesDiv" style="width:100%;overflow:auto;padding-top:15px;padding-bottom:15px;">
						<span style="font-style:italic">Please select an item.</span>
					</div>
					<div class="center">
						<br />
						<button value="Apply" dojoType="dijit.form.Button" onClick="if(propertiesManager) propertiesManager.applyProperties();">Apply</button>
						<button value="Delete" dojoType="dijit.form.Button" onClick="if(propertiesManager && confirm('Delete this component?')){propertiesManager.deleteItem();}">Delete</button>
					</div>
				</div>
            </div>
			
			<!--Status bar-->
			<div dojoType="dijit.layout.ContentPane" region="bottom" id="bottomPane">
                <table style="width:100%">
                    <tr>
                        <td id="statusBar">
                            Ready...
                        </td>
                        <td style="text-align:right">
                            <?php echo $_SESSION["username"] ?>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        
		<?php require_once("page_components/gui_support.html"); ?>
		
        <script type="text/javascript" src="dev/dev.js"></script>
		<script	type="text/javascript" 
				src="lib/dojo/dojo.js" 
				djConfig="parseOnLoad:true,modulePaths: {uws: '../uws'},
				isDebug:true, gfxRenderer:'svg,vml,canvas,silverlight'
				">
		</script>
		
		<!--Darn you, IE.-->
		<!--[if IE]>
		<script	type="text/javascript" src="lib/uws/Data.js"></script>
		<script	type="text/javascript" src="lib/uws/Drawing.js"></script>
		<script	type="text/javascript" src="lib/uws/Main.js"></script>
		<script	type="text/javascript" src="lib/uws/Menu.js"></script>
		<script	type="text/javascript" src="lib/uws/Tree.js"></script>
		<![endif]-->
        
		<script type="text/javascript">
			//if the device is capable of iphone level of viewing, set the flag
			var isMobile = <?php echo $uaInfo->DetectTierIphone(); ?>;
			(function(){
				try{
					//load modules
					dojo.require("uws.Drawing");
					dojo.require("uws.Main");
					dojo.require("uws.Menu");
					dojo.require("uws.Data");
					dojo.require("uws.Tree");
				}catch(e){
					//catch javascript parsing error aand alert the user/developer
					var obj = dojo.byId("loaderInner");
					obj.style.color = "black";
					obj.style.backgroundColor = "white";
					obj.style.width = "100%";
					obj.innerHTML="<p class='center'><img src='images/lg-failed-flat.png' alt='error'/></p><p class='center'>Sorry, a JavaScript error occured: " + e.message + "</p><br />";
				}
				
				dojo.addOnLoad(function(){
					//ask for confirmation on exit
					window.onbeforeunload=function(e){
						if(dataStore!=null && dataStore.isDirty()){
							e.returnValue = "You have made changes on this page that you have not yet saved. If you navigate away from this page you will loose your unsaved changes.";
						}
					}
					username = "<?php echo $_SESSION["username"]?>";
					
					try{
						loadDrawingModule(function(){
							hideLoader();
						});		//load the drawing modules
					}catch(e){
						var obj = dojo.byId("loaderInner");
						obj.style.color = "black";
						obj.style.backgroundColor = "white";
						obj.style.width = "100%";
						obj.innerHTML="<p class='center'><img src='images/lg-failed-flat.png' alt='error'/></p><p class='center'>Sorry, a JavaScript error occured: " + e.message + "</p><br />";
					}
				});
			})();
        </script>
    </body>
</html>
